home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10892 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  87 lines

  1. Path: news.wlv.ac.uk!usenet
  2. From: Mirad Maglic <c9583772@wlv.ac.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do you reset the computer using C on a PC ?
  5. Date: 20 Mar 1996 16:03:30 GMT
  6. Organization: University of Wolverhampton, U.K.
  7. Message-ID: <4ipa8i$2bb@ccuh.wlv.ac.uk>
  8. References: <31473FD4.48AA@ccis.com> <Pine.A32.3.91.960313183048.180818A-100000@red.weeg.uiowa.edu> <4ibj64$u2@hermes.is.co.za>
  9. NNTP-Posting-Host: ma154-bj.wlv.ac.uk
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  14.  
  15. jfk@teamserve.paradigm.co.za (Jan Kaluza) wrote:
  16. >The Amorphous Mass (robinson@blue.weeg.uiowa.edu) wrote:
  17. >: On Wed, 13 Mar 1996, Derek Lund wrote:
  18. >: 
  19. >: > Help?
  20. >: 
  21. >: int main(void)
  22. >: {
  23. >:     printf("press ctrl-alt-del.");
  24. >:     return 0;
  25. >: }
  26. >: 
  27. >:   For a more useful answer, try comp.os.msdos.programmer.help (or 
  28. >: comp.os.ms-windows.programmer, etc).
  29. >: 
  30. >: /**James Robinson***********************            
  31. >:   "If a fatal error occurs, the program should not be allowed to continue."
  32. >:  -- Oracle Pro*C User's Guide         *************james-robinson@uiowa.edu**/
  33. >
  34. >More seriously: when you want to reset the PC, call this function:
  35. >
  36. >void resetPC(void) {
  37. >  struct REGPACK rr;
  38. >  intr(25,&rr);
  39. >}
  40. >
  41. >This works for Turbo C/Borland C. For other compilers there must be an 
  42. >equivalent.  Interrupt 25 resets the PC in DOS. I found it hangs up a
  43. >DOS session in Windows rather nastily. 
  44. >-- 
  45. >Jan KALUZA: jfk@paradigm.co.za         [Box 4687, The Reeds, 0158, RSA] |Psalm
  46. >Genghis Janus (Std Disclaimer: My views are mine, mine and mine again!) |97:11
  47. >Light is sown as seed for the righteous and gladness for the upright in heart.
  48.  
  49.  
  50. Yeah, but you have to include dos.h. If you don't want to try this:
  51.  
  52.  
  53. /*
  54. Reboot from C
  55.  
  56. The program below works in TurboC (or MS C).  In some compilers, you
  57. have to fold the address to 20 bits, but here the segment and offset
  58. are separate.
  59. */
  60.  
  61. #define MAGIC           0               /* for cold restart */
  62. /* #define MAGIC           0x1234          /* for warm restart */
  63.  
  64. #define BOOT_SEG        0xffffL
  65. #define BOOT_OFF        0x0000L
  66. #define BOOT_ADR        ((BOOT_SEG << 16) | BOOT_OFF)
  67.  
  68. #define DOS_SEG         0x0040L
  69. #define RESET_FLAG      0x0072L
  70. #define RESET_ADR       ((DOS_SEG << 16) | RESET_FLAG)
  71.  
  72. void main()
  73. {
  74.         void ((far *fp)()) = (void (far *)()) BOOT_ADR;
  75.  
  76.         *(int far *)RESET_ADR = MAGIC;
  77.         (*fp)();
  78. }
  79.  
  80.  
  81. It works fine from DOS but Windows gives message that application has 
  82. *violated system integrity* whatever that means.
  83.  
  84.  
  85. Mirad Maglic (c9583772@wlv.ac.uk
  86.  
  87.